package pl.com.like.sequoia.web.beans.search;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import pl.com.like.sequoia.biojava.pdb.IPdbService;
import pl.com.like.sequoia.model.bio.BioObjectAlign;
import pl.com.like.sequoia.model.bio.BioObjectHandler;
import pl.com.like.sequoia.web.service.ISearchService;
import pl.com.like.sequoia.web.vo.SearchType;

public abstract class AbstractObjectBean implements Serializable {

	private static final long serialVersionUID = 32987L;
	private final static Logger log = LoggerFactory.getLogger(AbstractObjectBean.class);
	private ISearchService searchService;
	private IPdbService pdbService;

	public AbstractObjectBean() {
		super();
	}

	public BioObjectHandler getObject(String param) {
		if (log.isInfoEnabled()) {
			log.info("trying to get 1 PDB object with id {} ", param);
		}
		return searchService.findBioObject(param, SearchType.PDB);
	}

	public List<BioObjectAlign> getObjectAligns(String param) {
		if (log.isInfoEnabled()) {
			log.info("trying to get all counted alignments for object {}", param);
		}
		return searchService.findBioObjectAlignList(param, SearchType.PDB);
	}

	public IPdbService getPdbService() {
		return pdbService;
	}

	public ISearchService getSearchService() {
		return searchService;
	}

	public List<BioObjectHandler> search(String param, Integer page, Integer pageSize) {
		if (log.isInfoEnabled()) {
			log.info("trying to get list of PDB objects with id like {} ", param);
		}
		return searchService.findBioObjectList(param, SearchType.PDB, page, pageSize);
	}

	public void setPdbService(IPdbService pdbService) {
		this.pdbService = pdbService;
	}

	public void setSearchService(ISearchService searchService) {
		this.searchService = searchService;
	}

}